package com.microblogforsim.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.microblogforsim.R;
import com.microblogforsim.fragment.Icon;

import java.util.ArrayList;

public class IconAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<Icon> icons;

    public IconAdapter(Context context, ArrayList<Icon> icons) {
        this.context = context;
        this.icons = icons;
    }

    @Override
    public int getCount() {
        return icons.size();
    }

    @Override
    public Object getItem(int position) {
        return icons.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.view_page_find_list_item,null);
        ImageView iv_icon = convertView.findViewById(R.id.view_pager_find_list_item_img);
        TextView tv_title = convertView.findViewById(R.id.view_pager_find_list_item_title);
        iv_icon.setImageResource(icons.get(position).getIcon());
        iv_icon.setBackgroundResource(icons.get(position).getBg());
        tv_title.setText(icons.get(position).getTitle());
        return convertView;
    }
}
